﻿// radio-divlist
// 黑米 2010-3-30

// 
RadioDivList = function(containterId, itemTag, eventName) {
    this.container = containterId;
    if (!eventName) {
        eventName = "onmouseover";
    }
    RadioDivList.prototype.get = function(id, tag) {
        var ele = document.getElementById(id);
        if (tag && ele) {
            return ele.getElementsByTagName(tag);
        }
        else {
            return ele;
        }
    }

    this.lastSelected = null;
    this.items = this.get(containterId, itemTag);
    if (this.items) {
        for (var i = 0; i < this.items.length; i++) {
            this.items[i].listObject = this;
            this.items[i].className = "unselected";
            this.items[i][eventName] = function() {
                if (this.listObject.lastSelected) {
                    this.listObject.lastSelected.className = "unselected";
                }
                this.className = "selectedmode";
                this.listObject.lastSelected = this;
            }
        }
    }
}
